package bm.com.project.server.organization.controller;

import bm.com.framework.common.config.EnumRoute;
import bm.com.project.server.VerifyController;
import bm.com.project.server.common.dto.SearchBaseDTO;
import bm.com.project.server.organization.entity.BmOrgDepartmentEntity;
import bm.com.project.server.organization.service.DepartmentService;
import bm.com.framework.common.resp.PageVO;
import bm.com.framework.common.resp.Result;
import bm.com.framework.common.resp.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(EnumRoute.OrgRoute.Base)
public class DepartmentController extends VerifyController {

    @Autowired
    DepartmentService departmentService;

    @PostMapping(EnumRoute.OrgRoute.Department.LIST)
    public ResultVO getListPage(@RequestBody SearchBaseDTO queue){
        PageVO<List> listPage = departmentService.getListPage(queue);
        return ResultVO.success(listPage);
    }

    @PostMapping(EnumRoute.OrgRoute.Department.LIST_ALL)
    public ResultVO getListAll(){
        List<BmOrgDepartmentEntity> listAll = departmentService.getListAll();
        return ResultVO.success(listAll);
    }

    @PostMapping(EnumRoute.OrgRoute.Department.DETAIL)
    public Result<BmOrgDepartmentEntity> getDetail(@RequestParam(name = "departmentId") int departmentId){
        BmOrgDepartmentEntity detail = departmentService.getDetail(departmentId);
        return new Result<BmOrgDepartmentEntity>().ok(detail);
    }

}
